home *** CD-ROM | disk | FTP | other *** search
/ The Guided Tour of Multimedia (Second Edition) / The Guided Tour of Multimedia (Second Edition).iso / trials / qtw111 / samples / raw16.asm < prev    next >
Assembly Source File  |  1993-03-24  |  3KB  |  91 lines

  1.  
  2. ; ---------------------------------------------------------------------
  3. ;
  4. ; RAW16.ASM    - QuickTime for Windows Sample Decompressor
  5. ;
  6. ;                Version 1.1
  7. ;
  8. ;                (c) 1988-1993 Apple Computer, Inc. All Rights Reserved.
  9. ;
  10. ; ---------------------------------------------------------------------
  11.  
  12.  
  13. INCLUDE  QTMACROS.INC
  14.  
  15. CODESEG  SEGMENT PARA USE16 PUBLIC 'CODE'
  16.          OPTION  LANGUAGE:PASCAL
  17.         .386
  18.  
  19. OnePixel MACRO   source:REQ, target:REQ
  20.          MOV     AX, [ESI+source]      ;; Get a word
  21.          ROL     AX, 8                 ;; Flip the bytes
  22.          MOV     ES:[EDI+target], AX   ;; Store the word
  23.          ENDM
  24.  
  25. OnePixelInPlace MACRO   offst:REQ
  26.          ROL     WORD PTR [ESI+offst], 8  ;; Flip the bytes
  27.          ENDM
  28.  
  29. DecompressRaw16 PROC USES SI DI DS ES, Inbuf:FAR PTR, Outbuf:FAR PTR,
  30.                  BCOUNT:DWORD
  31.  
  32.          XOR     ESI, ESI         ; Zero out high order word
  33.          XOR     ESI, ESI         ; Initialize high order word
  34.          LDS     SI, Inbuf        ; DS:ESI = compressed buffer
  35.          XOR     EDI, EDI         ; Initialize high order word
  36.          LES     DI, Outbuf       ; ES:EDI = uncompressed buffer
  37.          MOV     ECX, BCOUNT      ; Get buffer size in bytes
  38.          SHR     ECX, 1           ; Convert to size in words, drop odd byte
  39.          MOV     DX, CX           ; Isolate remainder mod 8
  40.          AND     DX, 7            ;
  41.          SHR     ECX, 3           ; Compute number of 8-pixel groups
  42.          MOV     EAX, Inbuf       ; Are source and target buffers identical?
  43.          CMP     EAX, Outbuf      ;
  44.          JE      FlipInPlace      ; Skip if identical
  45.          ALIGN   16
  46. Loop8A:
  47. i        =       0
  48.          REPEAT  8
  49.          OnePixel  i,  i
  50. i        =       i + 2
  51.          ENDM
  52.          ADD     ESI, i           ; Advance source pointer
  53.          ADD     EDI, i           ; Advance target pointer
  54.          DEC     ECX              ; One fewer group to process
  55.          JG      Loop8A           ; Loop once for each group of 8 pixels
  56.          TEST    DX, DX           ; Any pixels remaining?
  57.          JE      Done             ; Skip if none remaining
  58. Loop1A:
  59.          OnePixel 0, 0            ; Process one pixel
  60.          ADD      ESI, 2          ; Advance source pointer
  61.          ADD      EDI, 2          ; Advance target pointer
  62.          DEC      DX              ; One fewer pixel to process
  63.          JG       Loop1A          ; Loop once for each pixel
  64. Done:
  65.          RET                      ; Return to caller
  66.  
  67.          ALIGN   16
  68. FlipInPlace:
  69. Loop8B:
  70. i        =       0
  71.          REPEAT  8
  72.          OnePixelInPlace  i
  73. i        =       i + 2
  74.          ENDM
  75.          ADD     ESI, i           ; Advance source pointer
  76.          DEC     ECX              ; One fewer group to process
  77.          JG      Loop8B           ; Loop once for each group of 8 pixels
  78.          TEST    DX, DX           ; Any pixels remaining?
  79.          JE      Done             ; Skip if none remaining
  80. Loop1B:
  81.          OnePixelInPlace 0        ; Process one pixel
  82.          ADD      ESI, 2          ; Advance source pointer
  83.          DEC      DX              ; One fewer pixel to process
  84.          JG       Loop1B          ; Loop once for each pixel
  85.          JMP      Done            ; Go to common exit
  86.  
  87. DecompressRaw16 ENDP
  88.  
  89. CODESEG  ENDS
  90.          END
  91.